package com.jumlabs.data.eventlisteners;

import javax.persistence.PrePersist;
import com.jumlabs.data.entities.drive.Drive;
import com.jumlabs.data.entities.drive.File;
import java.util.UUID;

public class PrimaryKeyEntityListener {

	@PrePersist
	public void setUUIDPrimaryKey(Object o) {
		String uuid=UUID.randomUUID().toString();
		if(o instanceof Drive){
			Drive d=(Drive)o;
			d.setId(uuid);
		}
		else if(o instanceof File){
			File f=(File)o;
			f.setId(uuid);
		}
	}

}
